## Attention This library should be completely independent of the Simulation
## 			 project so that it can be included in different programs.

CPPFILES = $(shell ls *.cpp)
HPPFILES = $(shell ls *.hpp)
OFILES   = $(CPPFILES:%.cpp=%.o)
CC       = @CGCC@



#CFLAGS :=-Wall -fopenmp

ifdef USE_GCOV
	#ifeq (echo "$CFLAGS" | grep "-fprofile-arcs -ftest-coverage",)
		CFLAGS += -fprofile-arcs -ftest-coverage
	#endif
endif

libSymbolic.a: $(OFILES)
	rm -f libSymbolic.a
	ar -r libSymbolic.a $(OFILES)
	ar -t libSymbolic.a

%.o: %.cpp $(HPPFILES)
	$(CC) $(CFLAGS) $(OPT) -c $<

# build documentation - not automatically
doc:
	@echo "================= Building Documentation ===================="
	doxygen Doxyfile > doxygen.log
	@echo "See doxygen.log for further information"

install: libSymbolic.a
	@echo "================= Installing Symbolic ======================="
	@echo "Installing into  @prefix@/stow/mylibs/"

	mkdir -p @prefix@/stow/mylibs/bin
	mkdir -p @prefix@/stow/mylibs/lib
	mkdir -p @prefix@/stow/mylibs/include/Symbolic;

	install --mode=755 Symbolic-config @prefix@/stow/mylibs/bin/Symbolic-config

	install --mode=744 *.a @prefix@/stow/mylibs/lib/;
	sed 's/#include[ \t]*"\([^"]*\)"/#include "Symbolic\/\1"/g' Symbolic.hpp > @prefix@/stow/mylibs/include/Symbolic.hpp
	install --mode=744 *.h *.hpp @prefix@/stow/mylibs/include/Symbolic/;
	@echo "=============================================================="

uninstall:
	cd @prefix@/stow/mylibs/include/ && rm -rfv Symbolic Symbolic.hpp && cd -;
	cd @prefix@/stow/mylibs/lib/ && rm -fv libSymbolic.a && cd -;
	cd @prefix@/stow/mylibs/bin/ && rm -fv Symbolic-config && cd -;

clean:
	@echo "======================== Clean Up ==========================="
	rm -rif *.o doxygen.log libSymbolic.a
	make -C Testing clean
	rm -rif doc latex
